package org.bootlimn.common;

/**
 * @author satya
 * This class defines the structure of a process element as outputed by processinfo and functions
 * to access the individual attributes
 *
 */

	public class Process {

		private int time;				// timestamp
		private int pid;				// process id
		private int ppid;				// parent process id
		private String execname;		// name of process name
	    private String probefunc;		// name of the function that was probed
	    private String pexecname;		// name of the parent process
	    private String misc;			// for any miscellaneous information
			
	    /**
		 * constructor
		 * @param	time				for timestamping
		 * @param	pid					for process id
		 * @param	ppid				for parent process id
		 * @return
		 * @throws IOException            if an I/O error occurs
		 */
		public Process(int time, int pid, int ppid, String execname, String probefunc, String pexecname, String misc) {
			this.time = time;
			this.pid = pid;
			this.ppid  = ppid ;
			this.execname = execname;
	        this.probefunc = probefunc;
	        this.pexecname = pexecname;	
	        this.misc = misc;
		}
		
		public Process()
		{
			this.time = 0;
			this.pid = 0;
			this.ppid  = 0 ;
			this.execname = "";
	        this.probefunc = "";
	        this.pexecname = "";
	        this.misc = "";
		}

		//functions to access individual attributes

		public int getTime() {
			return time;
		}

		public void setTime(int time) {
			this.time = time;
		}

		public int getPid() {
			return pid;
		}
	       
	        public void setPid(int pid) {
			this.pid = pid;
		}

	        public int getPpid() {
			return ppid;
		}

		public void setPpid(int ppid) {
			this.ppid = ppid;
		}

		public String getExecname() {
			return execname;
		}

		public void setExecname(String execname) {
			this.execname = execname;
		}

	        public String getProbefunc() {
			return probefunc;
		}

		public void setProbefunc(String probefunc) {
			this.probefunc = probefunc;
		}
			
		public String getPexecname() {
			return pexecname;
		}

		public void setPexecname(String pexecname) {
			this.pexecname = pexecname;
		}
		
		public String getMisc() {
			return misc;
		}

		public void setMisc(String misc) {
			this.misc = misc;
		}
		
		// To print it all out (temporary for text output purpose)
		
		public String toString() {
			StringBuffer sb = new StringBuffer();
			sb.append("Process Details - ");
			sb.append("Time" + getTime());
			sb.append(", ");
			sb.append("Pid" + getPid());
			sb.append(", ");
			sb.append("PPid:" + getPpid());
			sb.append(", ");
			sb.append("Execname:" + getExecname());
			sb.append(",");
			sb.append("Probefunc:" + getProbefunc());
			sb.append(",");
			sb.append("Pexecname:" + getPexecname());
			sb.append(",");
			sb.append("Misc:" + getMisc());
			sb.append(".\n");
			
			return sb.toString();
		}

}
